package com.javaweb.homework;

import com.javaweb.JDBCUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
 * @author: XiangHu
 * @date: 2025年02月27日  19:09
 * @describe:
 */

@WebServlet("/delete")
public class delete extends HttpServlet {

    // 处理get请求
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 设置请求编码
        req.setCharacterEncoding("UTF-8");
        // 设置响应编码
        resp.setCharacterEncoding("UTF-8");
        // 设置请求参数
        String id = req.getParameter("id");
        JDBCUtils.update("delete from stu where id = ?",id);
        resp.getWriter().print("删除成功！");
    }
}
